package com.example.park2212.emp

import androidx.lifecycle.MutableLiveData
import com.example.lib_base.entity.DepartBean
import com.example.lib_base.entity.EmpBean
import com.example.lib_base.entity.EmpBeanItem
import com.example.lib_base.mvvm.BaseViewModel
import com.example.lib_base.net.ApiService
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class EmpViewModel @Inject constructor(val apiservice: ApiService) :BaseViewModel() {

    var getEmpsSuccess = MutableLiveData<EmpBean>()
    fun getEmp(){
        httpRequest({
            apiservice.getEmp()
        },getEmpsSuccess::postValue)
    }

    var getDepartSuccess = MutableLiveData<DepartBean>()
    fun getDepart(){
        httpRequest({
            apiservice.getDepart()
        },getDepartSuccess::postValue)
    }

    val addEmpSuccess = MutableLiveData<EmpBeanItem>()
    fun addEmp(item: EmpBeanItem){
        httpRequest({
            apiservice.addEmp(mapToBody(item))
        },addEmpSuccess::postValue)
    }

}